package com.backend.repository;

import com.backend.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface UserRepository extends JpaRepository<User,Integer> {
    @Query(value = "select ifnull((select max(id) from user),0)",nativeQuery = true)
    public int getMaxId();
    @Query(value="select * from user where name = ?1 limit 1",nativeQuery = true)
    public User findUserByName (@Param("name") String name);
    @Query(value = "select * from user where email =?1 limit 1",nativeQuery = true)
    public User findUserByEmail(@Param("email") String email);
}
